const Router = require('koa-router')

const { auth } = require('../middleware/auth.middleware')
const { validator } = require('../middleware/orders.middleware')

const { create, findAll, update } = require('../controller/orders.controller')
const router = new Router({ prefix: '/orders' })

// 创建订单
router.post('/', auth, validator({
 address_id: 'int',
 goods_info: 'string',
 total: 'string'
}), create)
// 查看订单列表
router.get('/', auth, findAll)
// 修改订单
router.patch('/:id', auth, validator({ status: 'number' }), update)


module.exports = router